package p1;

import java.util.Random;

public class T09 {
    public static void main(String[] args) {
        Animal[] ans=new Animal[10];
        Random r=new Random();
        for(int i=0;i<10;i++){
            if(r.nextBoolean()){
                ans[i]=new Dog();
            }
            else{
                ans[i]=new Cat();
            }
        }
        int cats=0;
        for(Animal a:ans){
            if(a instanceof Cat)cats++;
        }
        System.out.printf("猫有%d只，狗有%d只\n",cats,10-cats);
    }
}
class Animal{

}
class Cat extends Animal{

}
class Dog extends Animal{

}